#!/usr/bin/python
"""
convert ptb-style tree (multi-line tree) to single line
"""

import sys, os

lines=[]
for l in sys.stdin.readlines():
	lines.append(l.strip())
sentstr="\n".join(lines)
sents=sentstr.split("\n\n")
sys.stderr.write("Total trees(sentences) count: "+str(len(sents))+"\n")

treelines=[]
for sen in sents:
	newsen=sen.replace("\n"," ")
	while True:
		newsen = newsen.replace("  "," ")
		#sys.stderr.write(newsen)
		if newsen.find("  ")<0:
			break
	treelines.append(newsen)
	sys.stdout.write(newsen+"\n")
